package com.graduation.rescuematerial.controller.applet;

import com.graduation.rescuematerial.service.UserService;
import com.graduation.rescuematerial.vo.RespBean;
import com.graduation.rescuematerial.vo.RespBeanEnum;
import com.graduation.rescuematerial.vo.UserVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @Author:CaiShuangLian
 * @FileName:
 * @Date:Created in  2022/5/7 18:59
 * @Version:
 * @Description:TODO
 */
@RestController
@RequestMapping("/applet/user")
@Api(tags = "Applet——用户模块")
public class AppletUserController {
    @Autowired
    private UserService userService;

    @ApiOperation("获取本部门成员")
    @ResponseBody
    @PostMapping("/company/list")
    public RespBean getListByCompanyName(@RequestBody String ticket, HttpServletRequest request, HttpServletResponse response){
        if(ticket!=null && !ticket.isEmpty()){
            //根据cookie获取用户信息
            UserVo userVo=userService.getUserByCookie(ticket,request,response);
            if(userVo!=null){
                String companyName=userVo.getCompanyName();
                return userService.getListByCompanyName(companyName,userVo.getAction());
            }
            return RespBean.error(RespBeanEnum.NO_OPERATION_PERMISSION,"非系统管理员，无法查看");
        }
        return RespBean.error(RespBeanEnum.ILLEGAL_OPERATION);
    }

   //修改用户状态：sys_cancel_user(注销用户)

   //修改用户个人信息，user_updateUserInfo（修改用户基本信息）

}
